<template>
  <el-container>
    <el-header>
      <headPart></headPart>
    </el-header>
    <el-main>
      <template>
        <div class="w">
          <h2 class="title">
            <span class="el-icon-office-building"></span><i>房屋具体信息</i>
          </h2>
          <div class="content">
            <div class="cover">
              <div class="bigImage">
                <h1>房产名称:{{ propertyInfo.title }}</h1>
                房产图片:&nbsp;&nbsp;<img
                  :src="propertyInfo.image"
                  alt=""
                  v-imagerror="defaultImg"
                />
              </div>
              <div class="photos">
                <h2>封面图片:</h2>
                <span v-for="(item, index) in propertyInfo.photos" :key="index">
                  <img :src="item.url" alt="" v-imagerror="defaultImg" />
                </span>
              </div>
            </div>
            <div class="message">
              主要介绍:
              <div v-html="propertyInfo.content"></div>
            </div>
          </div>
        </div>
      </template>
    </el-main>
    <el-footer>
      <footerPart></footerPart>
    </el-footer>
  </el-container>
</template>

<script>
import footerPart from "@/Layout/footer/index.vue";
import headPart from "@/Layout/head/index.vue";
import { getProperties } from "@/api/hotel.js";

export default {
  components: {
    footerPart,
    headPart,
  },
  data() {
    return {
      propertyInfo: {},
      id: "",
      defaultImg: require("@/assets/default.jpg"),
    };
  },
  created() {
    console.log(61, this.$route);
    this.getProperties();
  },
  methods: {
    async getProperties() {
      this.id = this.$route.params.id;
      const { data } = await getProperties(this.id);
      console.log(43, data);
      this.propertyInfo = data;
    },
  },
};
</script>

<style lang="less" scoped>
* {
  margin: 0;
  padding: 0;
}
.w {
  width: 1200px;
  margin: 0 auto;
  .title {
    text-align: left;
    text-indent: 2em;
    margin: 15px 0;
    font-weight: 400;
    color: orange;
    font-size: 20px;
    i {
      font-weight: 400;
    }
  }
  .content {
    // display: flex;
    border: 1px solid #ccc;
    margin-bottom: 20px;
    .cover {
      height: 400px;
      //   background-color: yellow;
      border-bottom: 1px solid #ccc;
      display: flex;
      .bigImage {
        padding: 20px 10px 0;
        flex: 1;
        border-right: 1px solid #ccc;
        h1 {
          font-weight: 700;
        }
        img {
          margin-top: 20px;
          width: 500px;
          height: 300px;
          vertical-align: middle;
        }
      }
      .photos {
        flex: 1;
        padding: 20px;
        // background-color: #0a0;
        h2 {
          font-weight: 400;
          text-align: left;
          margin-bottom: 20px;
        }
        img {
          width: 100px;
          height: 100px;
        }
      }
    }
    .message {
      padding: 20px;
      text-align: left;
    }
  }
}
</style>
